home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d17 / laser34c.arc / BIN_TEST.PAS next >
Pascal/Delphi Source File  |  1990-04-24  |  2KB  |  55 lines

  1. Program Bin_test;
  2. {$E+}
  3.  
  4. {This program test the ability of the plotting program to handle
  5.  binary data files.}
  6.  
  7. Var
  8.   Data_file:    File of single;
  9.   I:            Integer;
  10.   J:            Integer;
  11.   No_of_lines:  single;
  12.   No_of_points: single;
  13.   Data:         single;
  14.   Negative_one: single;
  15.   Zero:         single;
  16.   Header1:      String[50];
  17.   Header2:      String[50];
  18.   singleOrd:    single;
  19.  
  20. Begin
  21.   Negative_one := -1.0;
  22.   Zero := 0.0;
  23.   Header1 := 'Binary data file: example data';
  24.   Header2 := '(This label is included in the data file)';
  25.   No_of_lines := 2.0;
  26.   No_of_points := 5.0;
  27.   Assign(Data_file, 'Bin_test.dat');
  28.   Rewrite(Data_file);
  29.  
  30.   {This section shows the method by which a label may be placed in a binary
  31.    data file.  It could be omitted entirely and the program would still work.}
  32.   Write(Data_file, negative_one);    {indicates a label is in the file}
  33.   For I:=1 to Length(Header1) do     {Write header 1}
  34.   Begin
  35.     singleOrd := Ord(Header1[I]);      {Find a single number which is the}
  36.     Write(Data_file, singleOrd);       {  ascii value for the character}
  37.   End;
  38.   Write(Data_file, Zero);            {Indicates the end of header1}
  39.   For I:=1 to Length(Header2) do     {Write header 2}
  40.   Begin
  41.     singleOrd := Ord(Header2[I]);      {Find a single number which is the}
  42.     Write(Data_file, singleOrd);       {  ascii value for the character}
  43.   End;
  44.   Write(Data_file, Zero);            {Indicates the end of header2}
  45.  
  46.   Write(Data_file, No_of_lines);
  47.   Write(Data_file, No_of_points);
  48.   For I:=1 to Round(No_of_lines) do
  49.     For J:=1 to Round(No_of_points) do
  50.     Begin
  51.       Data := 1.0 * I / J;
  52.       Write(Data_file, Data);
  53.     End;
  54.   Close(Data_file);
  55. End.